home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20000824-20010305 / 000364_news@columbia.edu _Mon Feb 26 09:47:02 2001.msg < prev    next >
Internet Message Format  |  2020-01-01  |  3KB

  1. Return-Path: <news@columbia.edu>
  2. Received: from watsun.cc.columbia.edu (watsun.cc.columbia.edu [128.59.39.2])
  3.     by fozimane.cc.columbia.edu (8.9.3/8.9.3) with ESMTP id JAA18284
  4.     for <kermit.misc@cpunix.cc.columbia.edu>; Mon, 26 Feb 2001 09:46:33 -0500 (EST)
  5. Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.59.30])
  6.     by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id JAA07247
  7.     for <kermit.misc@watsun.cc.columbia.edu>; Mon, 26 Feb 2001 09:46:32 -0500 (EST)
  8. Received: (from news@localhost)
  9.     by newsmaster.cc.columbia.edu (8.9.3/8.9.3) id JAA22542
  10.     for kermit.misc@watsun.cc.columbia.edu; Mon, 26 Feb 2001 09:26:25 -0500 (EST)
  11. X-Authentication-Warning: newsmaster.cc.columbia.edu: news set sender to <news> using -f
  12. From: fdc@columbia.edu (Frank da Cruz)
  13. Subject: Re: FTP scripting...
  14. Date: 26 Feb 2001 14:26:24 GMT
  15. Organization: Columbia University
  16. Message-ID: <97dp2g$m0b$1@newsmaster.cc.columbia.edu>
  17. To: kermit.misc@columbia.edu
  18.  
  19. In article <3A9A0C8C.4D85005C@fujitsu-siemens.com>,
  20. Josef Moellers  <josef.moellers@fujitsu-siemens.com> wrote:
  21. : Grant Edwards wrote:
  22. : > In article <wkbsruo94c.fsf@mail.hex.net>, cbbrowne@hex.net wrote:
  23. : > >>>>>> "Rene Scheibe <Rene.Scheibe@gmx.net> writes:
  24. : > > Rene> ....can someone tell me if the normal ftp-client is
  25. : > > Rene> scriptable???  How can I write a script for it.  Can you
  26. : > > Rene> give me an example???  I want to login to a server and put
  27. : > > Rene> a file on it.
  28. : > >
  29. : > >You might try something like the following:
  30. : > >
  31. : > >#!/bin/ksh
  32. : > >ftp -n 172.28.211.99 << EOD
  33. : > >        user cbbrowne MySecretPassword
  34. : > >        cd /tmp
  35. : > >        binary
  36. : > >        put somefile.txt
  37. : > >        bye
  38. : > >EOD
  39. : ... or look at the netrc concept. I've written a number of scripts that
  40. : generate .netrc files on-the-fly and remove them when the access is
  41. : done.
  42. That's exactly why .netrc is not such a great idea.  It's the tail wagging
  43. the dog; you really want it the other way around -- an FTP client that can
  44. run any script you want without having to change (and remember to put back)
  45. some magic file.
  46.  
  47. Here's how you would do it with the new C-Kermit FTP client:
  48.  
  49.   #!/usr/local/bin/kermit
  50.   ftp 172.28.211.99 /user:cbbrowne /password:MySecretPassword
  51.   if fail exit 1 FTP connection failed
  52.   ftp cd /tmp
  53.   if fail exit 1 FTP CD failed
  54.   put /binary somefile.txt
  55.   if fail exit 1 FTP PUT failed
  56.   bye
  57.  
  58. Note that each operation can be checked for failure.  Also note that it's
  59. not a great idea to put passwords in files, so you can have Kermit prompt
  60. you for the password:
  61.  
  62.   ftp 172.28.211.99 /user:cbbrowne
  63.   if fail exit 1 FTP connection failed
  64.   
  65. Just leave out the password and the prompting occurs automatically.
  66. Of course if you want the script to run unattended, prompting for the
  67. password is not practical, but there are ways around that too.
  68.  
  69. By the way, this is a very simple application for FTP scripting.  So
  70. simple, in fact, that Kermit can do it without a script.  If you have a
  71. symlink "ftp" to the C-Kermit 7.1 binary, you can just give it this
  72. command line:
  73.  
  74.   ftp 172.28.211.99 -u cbbrowne -P MySecretPassword -D /tmp -p somefile.txt
  75.  
  76. For more demanding examples, see:
  77.  
  78.   http://www.columbia.edu/kermit/ftpscript.html
  79.  
  80. - Frank